<?php
use kartik\file\FileInput;
use yii\helpers\Url;
use yii\bootstrap\ActiveForm;
\app\assets\AdminUpload::register($this);
?>
<?php
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php echo Yii::$app->language; ?>">
<head>
    <?php
    $this->registerMetaTag(["name" => "viewport", "content" => "width=device-width, initial-scale=1.0"]);
    $this->registerMetaTag(["http-equiv" => "Content-type", "content" => "text/html;charset=utf-8"]);
    $this->head();
    ?>
</head>
<body>

        <?php
        $picid=Yii::$app->request->get('picid')?:'';
        $inputid=Yii::$app->request->get('inputid')?:'';
        $form = ActiveForm::begin([
            'options' => ['enctype'=>'multipart/form-data'],
        ]);
       // echo '<label class="control-label">上传图片</label>';
        echo FileInput::widget([
            'name' => 'cover',
            'pluginOptions' => [
                'multiple' => true,
                'uploadUrl' => Url::to(['/admin/upload/image']),     // 异步上传的接口地址设置
                'uploadAsync' => true,
                'showPreview' => false,//去除预览功能
                'showCaption' => true,
                'showRemove' => false,
                'showUpload' => true,
            ],
            'pluginEvents' => [
                "fileuploaded" => "function (event, data, id, index) {
                   var imgUrl=data.response.imgUrl;                  
                   $('.imgiframe',window.parent.document).parent().find('#$picid').attr('src',imgUrl);//获取父页面的方法  
                   $('.imgiframe',window.parent.document).parent().find('#$inputid').attr('value',imgUrl);   
                   //console.log(data);              
                }",
            ],
        ]);
        ?>
        <?php ActiveForm::end(); ?>

<?php $this->endBody(); ?>
</body>
</html>
<?php $this->endPage(); ?>



